function [ A, Z ] = assemblyMatrix( domain2D )
%ASSEMBLYMATRIX Summary of this function goes here
%   Detailed explanation goes here

n = size(domain2D.ex, 2);

A = diag(ones(2*n, 1)) * 0.5;
Z = ones(2*n, 2*n);

for i = 1 : n
    
   p = [domain2D.ex(i), domain2D.ey(i)];
   
   for j = 1 : n
       qi0 = j;
       qi1 = mod(j, n) + 1;
       
       q0 = [domain2D.x(qi0), domain2D.y(qi0)];
       q1 = [domain2D.x(qi1), domain2D.y(qi1)];
       
       qn = [domain2D.nx(j), domain2D.ny(j)];
       
       v0 = evaluateGradientQuadraturePoint(p, q0, qn);
       v1 = evaluateGradientQuadraturePoint(p, q1, qn);
       
       ql = domain2D.l(j);
       
       A(2*i-1:2*i, 2*j-1:2*j) = A(2*i-1:2*i, 2*j-1:2*j) + (v0 + v1) * ql / 2;
       
%        Z(2*i-1:2*i, 2*j-1:2*j) = Z(2*i-1:2*i, 2*j-1:2*j) * cond(A(2*i-1:2*i, 2*j-1:2*j));
       
%        if i == 1 && j == 2
%            
%           A(i, j) 
%           
%           v0
%           v1
%        end
   end
end

A = -1 * A;

end

